#!/bin/bash
. /etc/init.d/functions 
prefix='172.16.1.'
ip_nums='5 6 7 8 31 41 51'
password=1
for ip_num in $ip_nums;do
    ping -c 2 $prefix$ip_num &> /dev/null
    if [ $? -eq 0 ];then
        sshpass -p $password ssh-copy-id -i ~/.ssh/id_rsa.pub root@$prefix$ip_num -o StrictHostKeyChecking=no &> /dev/null
        if [ $? -eq 0 ];then
            action "$prefix$ip_num ssh-key" /bin/true
        else
            action "$prefix$ip_num ssh-key" /bin/false
        fi
    fi
done